﻿using System.Windows.Forms;
using ThinkDotNetEditorLib.Controllers;

namespace ThinkDotNetEditorLib
{
    public partial class ShelForm : Form,IShellForm
    {
        private readonly ShellController _controller; 
        public ShelForm()
        {
            InitializeComponent();            
            _controller=new ShellController(this);
            RefreshUndoRedoIsEnabled();
        }

        #region IShell Members

        public void RefreshUndoRedoIsEnabled()
        {
            undoToolStripButton3.Enabled = undoToolStripMenuItem.Enabled = _controller.CanUndo;
            redoToolStripButton4.Enabled = redoToolStripMenuItem.Enabled = _controller.CanRedo;
        }
        public Control XnaContainer
        {
            get { return arenaDrawerView1; }
        }
        public IGameEditor GameEditor { get;  set; }

        #endregion

        private void splitContainer1_Panel2_Resize(object sender, System.EventArgs e)
        {
            if(GameEditor!=null)
                GameEditor.Reset();
        }
        private void undoToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            _controller.Undo();
        }
        private void redoToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            _controller.Redo();
        }
        private void arenaDrawerView1_MouseDown(object sender, MouseEventArgs e)
        {
            XnaContainer.Focus();
        }
        private void removeToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            _controller.RemoveSelectedObjects();
        }
        private void saveToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            _controller.Save();            
        }
        private void openToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            _controller.Open();
        }
        private void saveAsToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            _controller.SaveAs();
        }
        private void exitToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            _controller.Exit();
        }
   
        private void aboutToolStripMenuItem_Click_1(object sender, System.EventArgs e)
        {
            _controller.ShowAboutBox();
        }     
    }
}
